package com.matrix.geo.playmysqlgeo.serializers;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.matrix.geo.playmysqlgeo.util.JtsUtil;
import org.locationtech.jts.geom.Geometry;

import java.io.IOException;

public class GeometryJacksonSerializer extends JsonSerializer<Geometry> {

    @Override
    public void serialize(Geometry geometry, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        jsonGenerator.writeObject(JtsUtil.geometry2JsonObject(geometry));
    }

}
